<%@ page import="java.util.List" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.Iterator" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.LinkedHashMap" %>
<%
            
            
            List<String> cats = new ArrayList<String>();
        	List<Double> ownValues2 = new ArrayList<Double>();
        	List<Double> averageValues2 = new ArrayList<Double>();
		   	Map<String, Double> averageMap2 = new LinkedHashMap<String, Double>();
	     	Map<String, Double> ownMap2 = new LinkedHashMap<String, Double>();
	     	double container2 = 0;
	     	String title2 = "";
	     	String subTitle2 = "";
	     	String yAxis2 = "";
	     	String unit2 = "";
	     	try {
	     	averageMap2 = (Map<String, Double>) session.getAttribute("averageMap");
	     	ownMap2 = (Map<String, Double>) session.getAttribute("ownMap");
	     	container2 = (Double) session.getAttribute("container");
	     	title2 = (String) session.getAttribute("title");
	     	subTitle2 = (String) session.getAttribute("subtitle");
	     	yAxis2 = (String) session.getAttribute("yAxis");
	     	unit2 = (String) session.getAttribute("unit");
	     	}
	     	finally
	     	{
	     		
	     	}
        	
        	 Iterator it = averageMap2.entrySet().iterator();
        		while (it.hasNext()) {
                Map.Entry pairs = (Map.Entry)it.next();
            	String catName = (String) pairs.getKey();
            	double averageValue = (Double) pairs.getValue();
            	double value=0;
            	if(ownMap2.containsKey(catName)){
            	value = (Double) ownMap2.get(catName);
            	}
            	ownValues2.add(value);
            	averageValues2.add(averageValue);
            	cats.add(catName);
           }
            
            %>
		
		
		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<script type="text/javascript">
$(function () {
    var chart;
    $(document).ready(function() {
    	<% if(container2==0){ %>
    	// Radialize the colors
		Highcharts.getOptions().colors = $.map(Highcharts.getOptions().colors, function(color) {
		    return {
		        radialGradient: { cx: 0.5, cy: 0.3, r: 0.7 },
		        stops: [
		            [0, color],
		            [1, Highcharts.Color(color).brighten(-0.3).get('rgb')] // darken
		        ]
		    };
		});
		<% } %>
		
        chart = new Highcharts.Chart({
            chart: {
            	backgroundColor: '#FFFFFF',
                renderTo: 'container<%=container2%>',
                type: 'column'
            },
       
            title: {
                text: '<%=title2%>'
            },
            subtitle: {
                text: '<%=subTitle2%>'
            },
            xAxis: {
                categories: [
                             <%  
                             int i =1;
                             for(String catName: cats){
                            	 
                       		    	%>
                            '<%=catName%>'<% if(i!=cats.size()){ %>,<%} i++; %>
                          
                            <% } %>

                ]
            },
            yAxis: {
                min: 0,
                title: {
                    text: '<%=yAxis2%>'
                }
            },
          
            tooltip: {
                formatter: function() {
                	
                    return ''+
                        this.x +': '+  Math.round(this.y*100)/100 +' <%=unit2%>';
                }
            },
            plotOptions: {
                column: {
                    pointPadding: 0.2,
                    borderWidth: 0
                }
            
            },
                series: [{
                name: 'You',
                data: [          <%  
                                 i =1;
                for(double value: ownValues2){
               	 
          		    	%>
               <%=value%><% if(i!=ownValues2.size()){ %>,<%} i++; %>
             
               <% } %>
]
                      
                       
                       
    
            }, {
                name: 'Average Student',
                data: [<%  
                        i =1;
                for(double averageValue: averageValues2){
               	 
          		    	%>
               <%=averageValue%><% if(i!=averageValues2.size()){ %>,<%} i++; %>
             
               <% } %>
]
              
    
            }]
        });
    });
    
});
		</script>
<script src="../Scripts/highcharts/js/highcharts.js"></script>
<script src="../Scripts/highcharts/js/modules/exporting.js"></script>

<div id="container<%=container2%>" style="min-width: 400px; height: 400px; margin: 0 auto"></div>

